<?php
class NaviMenu extends Portlet
{
	public $_menu = array(
						'copy'=>array(
								   array('label'=>'ads','url'=>'/copy/cover','navi'=>'ad-list'),
								   array('label'=>'probono','url'=>'/copy/probono','navi'=>'probono'),
								   array(),
								   array('label'=>'my_slogans','url'=>'/copy/slogans','navi'=>'my-slogan'),
								   array('label'=>'earnings','url'=>'/copy/earnings','navi'=>'earnings'),
								   array(),
								   array('label'=>'howto_copywrite','url'=>'/copy/howto','navi'=>'how-to'),
								   ),
						'adv'=>array(
								   array('label'=>'howto_advertise','url'=>'/adv/howto','navi'=>'how-to'),
								   array(),
								   array('label'=>'make_ad','url'=>'/adv/register','navi'=>'make-ad'),
								   array(),
								   array('label'=>'my_ads','url'=>'/adv/ads','navi'=>'my-ads'),
								   array('label'=>'payment','url'=>'/adv/billing','navi'=>'payment'),
								   ),
						'info'=>array(
								   array('label'=>'about','url'=>'/info/about','navi'=>'about'),
								   array('label'=>'contact_us','url'=>'/info/contact','navi'=>'contact-us'),
								   array('label'=>'faq','url'=>'/info/faq','navi'=>'how-to'),
								   ),
						'nouser'=>array(
								   array('label'=>'login','url'=>'/users/login','navi'=>'sign-in'),
								   array('label'=>'join','url'=>'/users/join','navi'=>'invite'),
								   array('label'=>'password_getback','url'=>'/users/forgetPw','navi'=>'password'),
								   ),
						'setting'=>array(
								   array('label'=>'setting','url'=>'/users/setting','navi'=>'setting'),
								   array('label'=>'password_change','url'=>'/users/passwd','navi'=>'password'),
								   ),		  
						);
	private $_controllerId = null;
	private $_navimenu = array('cover'=>'ad-list','ad'=>'ad-list',
							   'probono'=>'probono',
							   'slogans'=>'my-slogan',
							   'earnings'=>'earnings',	
							   'howto'=>'how-to',
							   'register'=>'make-ad',
								'ads'=>'my-ads',
								'billing'=>'payment',
								'login'=>'sign-in',
								'join'=>'invite',
								'forgetPw'=>'password',
								'setting'=>'setting',
								'passwd'=>'password',				
							);
	
	public function init()
	{
		$this->_controllerId = strtolower($this->getController()->id);
		if($this->_controllerId == 'users'){
			if(Yii::app()->user->isGuest)  $this->_controllerId = 'nouser';
			else $this->_controllerId = 'setting';
		}
		$navimenu = $this->_navimenu();
		$this->htmlOptions = array('id'=>'navi-col','navimenu'=>$navimenu,'navicol'=>$this->_controllerId);
		parent::init();
	}
	
	private function _navimenu(){
		$action = $this->getController()->action->id;
		return $this->_navimenu[$action];
	}

	protected function renderContent()
	{
		$this->render('naviMenu',array('menu'=>$this->_menu[$this->_controllerId]));
	}
}